﻿// set the css for top menu links
function anu()
{
}
function setmenucss(objli)
{
    var linksdiv= document.getElementById('toplinks');
    var menulinks=linksdiv.getElementsByTagName('li');
  
    for(var i=0;i<menulinks.length;i++)
    {
        if(objli!=i)
        {
        if(i==menulinks.length-1)
        {
        menulinks[i].className='';
        }
        else{
        menulinks[i].className='leftline';
        }
        }else{
        menulinks[i].className='leftline curr';
        }
    }
    //objli.className='leftline curr';
}

// show preview 
function showPreview(imgid,imgpath)
{
    document.getElementById(imgid).src=imgpath;
}
function assignValue(hidid,hidval,divid)
{    
    document.getElementById(divid).style.display='';
    document.getElementById(hidid).innerText=hidval;
    document.getElementById("checkout").style.display='';
}
// toggle div
function toggel(divid)
{
    var obj=document.getElementById(divid);
    if(obj)
    {
        if(obj.style.display=='')
        {
            obj.style.display='none';
        }
        else
             obj.style.display='';
    }
}
// loading menu
// ***** Popup Control *********************************************************

// ***** at_show_aux *****

function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

// ***** at_click *****

function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;
  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}










/* for google maps javascript */

function Googlemap_load(latitude,Longitude,id,zoom)
{
GUnload();
if (GBrowserIsCompatible()) 
    {
    //alert(document.getElementById(id));
 var map = new GMap2(document.getElementById(id));
 
 map.setCenter(new GLatLng(latitude, Longitude), zoom);
 map.setUIToDefault();
  marker = new GMarker(new GLatLng(latitude, Longitude), {draggable: false});
        map.addOverlay(marker);
 // Add 10 markers to the map at random locations
  // var bounds = map.getBounds();  var southWest = bounds.getSouthWest();  var northEast = bounds.getNorthEast();  var lngSpan = northEast.lng() - southWest.lng();  var latSpan = northEast.lat() - southWest.lat();  for (var i = 0; i < 10; i++) {    var point = new GLatLng(southWest.lat() + latSpan * Math.random(),        southWest.lng() + lngSpan * Math.random());    map.addOverlay(new GMarker(point));  }
 
 } 
}


var map = null;
var geocoder = null;
var latsgn = 1;
var lgsgn = 1;
var zm = 0; 
var marker = null;
var posset = 0;

function Googlemap_load1(latitude,Longitude,txtLat,txtLon)
{
    if (GBrowserIsCompatible()) 
    {
     var map = new GMap2(document.getElementById("gmap"));
     map.setCenter(new GLatLng(latitude, Longitude), 13);
     map.setUIToDefault();
     geocoder = new GClientGeocoder();
        marker = new GMarker(new GLatLng(latitude, Longitude), {draggable: true});
        map.addOverlay(marker);
        GEvent.addListener(map, 'click', function(overlay,point) 
        {if (overlay)     {}     else     {
        posset = 1;    //fc( point) ;    //marker.setPoint(point);
        if (zm == 0)    {map.setCenter(point,7); zm = 1;}    else    {map.setCenter(point);}    computepos(point,txtLat,txtLon);    }});
        
        
        GEvent.addListener(map, 'singlerightclick', function(point,src,overlay) 
        {if (overlay)  {if (overlay != marker){map.removeOverlay(overlay)
        document.getElementById(txtLon).value='';
        document.getElementById(txtLat).value='';
        } } else {}});
        GEvent.addListener(marker, "dragend", function() {var point = marker.getLatLng();posset = 1;        
        if (zm == 0){map.setCenter(point,7); zm = 1;}else{map.setCenter(point);} computepos(point,txtLat,txtLon);});
        GEvent.addListener(marker, "click", function() { var point = marker.getLatLng();
        marker.openInfoWindowHtml(marker.getLatLng().toUrlValue(6));
         computepos (point,txtLat,txtLon);});
    } //end if
    
}
function computepos (point,txtLat,txtLon)
{
var latA = Math.abs(Math.round(value=point.y * 1000000.));
var lonA = Math.abs(Math.round(value=point.x * 1000000.));
 
if(value=point.y < 0)
{
	var ls = '-' + Math.floor((latA / 1000000));
}
else
{
	var ls = Math.floor((latA / 1000000));
}
 
var lm = Math.floor(((latA/1000000) - Math.floor(latA/1000000)) * 60);
var ld = ( Math.floor(((((latA/1000000) - Math.floor(latA/1000000)) * 60) - Math.floor(((latA/1000000) - Math.floor(latA/1000000)) * 60)) * 100000) *60/100000 );
 
if(value=point.x < 0)
{
  var lgs = '-' + Math.floor((lonA / 1000000));
}
else
{
	var lgs = Math.floor((lonA / 1000000));
}
 
var lgm = Math.floor(((lonA/1000000) - Math.floor(lonA/1000000)) * 60);
var lgd = ( Math.floor(((((lonA/1000000) - Math.floor(lonA/1000000)) * 60) - Math.floor(((lonA/1000000) - Math.floor(lonA/1000000)) * 60)) * 100000) *60/100000 );
document.getElementById(txtLat).value=point.y;
document.getElementById(txtLon).value=point.x;

}

function fc( point )
{
  var map = new GMap2(document.getElementById("gmap"));
 var html = "";
 html += html + "Latitude, Longitude<br>" + point.toUrlValue(6);
 
 var baseIcon = new GIcon();
 baseIcon.iconSize=new GSize(32,32);
 baseIcon.shadowSize=new GSize(56,32);
 baseIcon.iconAnchor=new GPoint(16,32);
 //baseIcon.value="13";
 baseIcon.infoWindowAnchor=new GPoint(16,0);
 var thisicon = new GIcon(baseIcon, "../themeicons/blue-dot.png", null, "../themeicons/msmarker.shadow.png");
 
 var marker = new GMarker(point,thisicon);
 GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
 map.addOverlay(marker);
}
function showMapbyAddress(addrr,txtLat,txtLon) {
   
  var map = new GMap2(document.getElementById("gmap"));
   var add=document.getElementById(addrr).value;
 
 if (geocoder) {
 geocoder.getLatLng(
 add,
 function(point) {
 if (!point) {
 //alert(add + " not found");
 } else {
 posset = 1;
 map.setUIToDefault();
// map.setMapType(G_HYBRID_MAP);
 map.setCenter(point,12);
 zm = 1;
 marker.setPoint(point);
 //GEvent.trigger(marker, "click");
  map.setUIToDefault();
   geocoder = new GClientGeocoder();
        map.addOverlay(marker);
        GEvent.addListener(map, 'click', function(overlay,point) 
        {if (overlay)     {}     else     {
        posset = 1;    //fc( point) ;    //marker.setPoint(point);
        if (zm == 0)    {map.setCenter(point,7); zm = 1;}    else    {map.setCenter(point);}    computepos(point,txtLat,txtLon);    }});
        
        GEvent.addListener(map, 'singlerightclick', function(point,src,overlay) 
        {if (overlay)  {if (overlay != marker){map.removeOverlay(overlay)
        document.getElementById(txtLon).value='';
        document.getElementById(txtLat).value='';
        } } else {}});
        GEvent.addListener(marker, "dragend", function() {var point = marker.getLatLng();posset = 1;        
        if (zm == 0){map.setCenter(point,7); zm = 1;}else{map.setCenter(point);} computepos(point,txtLat,txtLon);});
        GEvent.addListener(marker, "click", function() { var point = marker.getLatLng();
        marker.openInfoWindowHtml(marker.getLatLng().toUrlValue(6)); computepos (point,txtLat,txtLon);});
 
 }
 }
 );
 }
}

/* google maps javascript ended */
function taskchange(ddlid,txtid,hrrate,hrid)
{
    var ddl=document.getElementById(ddlid);
    var txt=document.getElementById(txtid);
       
    if(ddl.value!="")
    {
        document.getElementById('lblamount').innerText=ddl.value;
        document.getElementById(hrid).style.display='none';
    }
    else
    { 
        document.getElementById(hrid).style.display='';
        if(hrrate!='Not Specified')
            document.getElementById('lblamount').innerText=eval(txt.value)*hrrate;
        else
            document.getElementById('lblamount').innerText=0;
    }
}

function checkall(chk, cont)
{

    var chcks=cont.split(',');
    
    for(var i=0;i<chcks.length-1;i++)
    {
         document.getElementById(chcks[i]).checked=chk.checked;
        
    }
}



/* pointing google map with order list*/
var  manager,markers;
function get_Orderlist1(id1)
{
PageMethods.Get_Orderlist(OnSuccess_Gmap,OnFailure_Gmap,id1);
 }
function OnSuccess_Gmap(result,id)
{
markers = [{'abbr': '30','name': 'Lower East Side','latitude':40.714737,'longitude':-73.986912,'wp':'http://en.wikipedia.org/wiki/Lower_East_Side%2C_Manhattan'},
{'abbr': '5','name': 'East Village','latitude':40.733145,'longitude':-73.987083,'wp':'http://en.wikipedia.org/wiki/East_Village%2C_Manhattan'},
{'abbr': '20','name': 'West Village','latitude':40.737047,'longitude':-74.005623,'wp':'http://en.wikipedia.org/wiki/West_Village%2C_Manhattan'},
{'abbr': '10','name': 'Upper East Side','latitude':40.775082,'longitude':-73.958588,'wp':'http://en.wikipedia.org/wiki/Upper_East_Side'}];
//add google map
if (GBrowserIsCompatible()) {
map = new GMap(document.getElementById(id));
                     map.addControl(new GSmallMapControl());
                             map.setCenter(new GLatLng(17.23,72.36), 4);
                                     map.addControl(new GMapTypeControl());
manager = new GMarkerManager(map);


       
//map.enableScrollWheelZoom();       
//map.addControl(new GLargeMapControl());
//map.addControl(new GMapTypeControl());
//map.setUIToDefault();
//manager = new GMarkerManager(map);
// This is a sorting trick, don't worry too much about it. 
markers.sort(function(a, b) { return (a.abbr > b.abbr) ? +1 : -1; });
batch = [];        
 for(id in markers) {batch.push(createMarker(markers[id]));} 
                       manager.addMarkers(batch, 11);
                              manager.refresh();
                 }

}
function OnFailure_Gmap(result)
{
//alert(result);
}
  function createMarker(pointData)
   {
var latlng = new GLatLng(pointData.latitude, pointData.longitude);
//alert(latlng);
var icon = new GIcon();
icon.image='http://gmaps-samples.googlecode.com/svn/trunk/markers/red/blank.png';
icon.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
icon.iconSize = new GSize(32, 32);
icon.iconAnchor = new GPoint(16, 16);
opts = {"icon": icon,"clickable": false,"draggable": false,"labelText": pointData.abbr,"labelOffset": new GSize(-16, -16)};
var marker = new LabeledMarker(latlng, opts);
return marker;
}

function searchbd(ddl1,ddl2,ddl3,txt)
{
    
}
//function htmlpaggeing(id1,id2,id3)
//{
//document.getElementById(id1).style.display='block';
// document.getElementById(id2).style.display='none';
//  document.getElementById(id3).style.display='none';
//}

function htmlpaggeing(id1,id2,id3,id4,id5,id6)
{
document.getElementById(id1).style.display='block';
 document.getElementById(id2).style.display='none';
  document.getElementById(id3).style.display='none';
  document.getElementById(id4).style.display='none';
 document.getElementById(id5).style.display='none';
  document.getElementById(id6).style.display='none';
}


/* timer */
var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;

function InitializeTimer()
{
    // Set the length of the timer, in seconds
   
    secs = 2;
    StopTheClock();
    StartTheTimer();
}
function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}
function StartTheTimer()
{ 
    if (secs==0)
    {
        StopTheClock();
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        //alert("You have just wasted 10 seconds of your life.")
       
        PageMethods.Get_TimeDiff(OnSuccess_Time,OnFailure_Time);
        
    }
    else
    {
        self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}
function OnSuccess_Time(result)
{
var time=result.split(','); 
var objh= document.getElementById('lbl_hours');

var objm= document.getElementById('lbl_minutes');
var objs= document.getElementById('lbl_seconds');

//alert(objs);
objh.innerHTML=time[0];
objm.innerHTML=time[1];
objs.innerHTML=time[2];
InitializeTimer();
}
function OnFailure_Time(result)
{
}


function sendsmsdta(com,phone,add,hid_compname,hid_comadd,hid_comtel,fname,fcell,fdesc,femail)
{
document.getElementById(fname ).value='';
document.getElementById(fcell ).value='';
document.getElementById(fdesc ).value='';
document.getElementById(femail).value='';

document.getElementById(hid_compname).value=com;
document.getElementById(hid_comadd).value=add;
document.getElementById(hid_comtel).value=phone;
document.getElementById('smsdiv').style.display='block';
}

function emailormobile()
{
//var controlValidate =document.getElementById(sender.controltovalidate);
//var txt_cell =document.getElementById(document.getElementById('txt_cell').value);
alert('dd');
 //args.IsValid=false;
 //return false;   
}