var popUp; 
var popUpIssue;
var popUpCEdit;

// Globals
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;


function toggle(id) 
{
	var d = document.getElementById(id);
	if(d != null)
		d.className = (d.className == "h") ? "s" : "h"; 
} 

function writetoplink() {
	document.write("[ <a class=link2 href='#top'>top</a> ]\r");
}

function OpenCalendar(idname, postBack)
{
popUp = window.open('/Utility/Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack
		,'popupcal', 
		'width=165,height=208,left=200,top=250');
}

function SetDate(formName, id, newDate, postBack)
{
	obj =document.getElementById(id);
	obj.value=newDate;	
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}		

//function added by gaurav to open density calculater on 24 june 2006.
function openDensityCalc(boxid,formid)
{
calurl="/Tools/Calculator.aspx?boxid="+boxid+"&formid="+formid;

 window.open(calurl,'calc','toolbar=0,location=5,scrollbars=0,directories=0,status=0,menubar=0,resizable=0,width=750,height=425');
}
function setDensity(formName,boxName,val)
{
   document.getElementById(boxName).value=val;
}

//function to load the Flash Dynamically to avoid the problem of inactivation
function LoadFlash(width, height, filePath, cx, cy,isHomePage,isLocationPage, alternateImageFilePath)
{

	// Version check based upon the values entered above in "Globals"
	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
   
	// Check to see if the version meets the requirements for playback
	if (hasReqestedVersion) {
		// if we've detected an acceptable version
		// embed the Flash Content SWF when all tests are passed
		document.write('<object width='+width+' height='+height+' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">');
		// classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
        document.write('<param name="URL" value="'+filePath+'">');
        document.write('<param name="_cx" value="'+cx+'">');
        document.write('<param name="_cy" value="'+cy+'">');
        document.write('<param name="Quality" value="High">');
        document.write('<param name="Menu" value="-1">');
        document.write('<param name="Scale" value="ShowAll">');
        document.write('<param name="DeviceFont" value="0">');
        document.write('<param name="WMode" value="WINDOW">');
        document.write('<param name="Src" value="'+filePath+'">');
        document.write('<param name="Play" value="1">');
        document.write('<param name="EmbedMovie" value="0">');
        document.write('<param name="autoStart" value="-1">')
        document.write('<param name="AllowScriptAccess" value="always">')
        document.write('<embed src="'+filePath+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+width+' height='+height+'> </embed>')    
        document.write('</object>');
	} else {  // flash is too old or we can't detect the plugin
	    // insert non-flash content
	    var alternateContent = '<font color="white"><strong>Flash plugin could not be detected or it is an older version. <a href="http://www.macromedia.com/go/getflash/" target="_blank" style="color:lightblue" >Please install/upgrade your Flash plugin.</a></strong></font>';
		document.write('<table width='+width+' height='+height+' cellpadding="0" cellspacing="0">');
        document.write('<tr>');
        document.write('<td>');
	    if(isHomePage || !isLocationPage) {	   
            
            // table which contians images like the flash one....
            document.write('<table width='+width+' border="0" align="center" cellpadding="0" cellspacing="0">');
            
            document.write('  <tr>');
            document.write('    <td align="center">')
            document.write("<div style='position: relative;'>");
            document.write("<img src='"+alternateImageFilePath+"' border='0' usemap='#Map'>"); 
            document.write("<map name='Map'>"); 
            document.write("<area shape='rect' coords='599,154,967,329' href='/services/drivers/'>"); 
            document.write("<area shape='rect' coords='5,156,596,329' href='/accounts/register.aspx'>"); 
            document.write("</map>");
            document.write("<div style='position: absolute; left: 680px; top: 18px;'>"); 
            document.write("<a class='menu' href='/tools/rates.aspx'>"); 
            document.write("Rate Quote");
            document.write("</a>"); 
            document.write("</div>"); 
            document.write("<div style='position: absolute; left: 680px; top: 47px;'>"); 
            document.write("<a class='menu' href='/tools/tracking/index.aspx'>"); 
            document.write("Tracking");
            document.write("</a>"); 
            document.write("</div>"); 
            document.write("<div style='position: absolute; left: 680px; top: 72px;'>"); 
            document.write("<a class='menu' href='/accounts/index.aspx'>"); 
            document.write("Account");
            document.write("</a>"); 
            document.write("</div>"); 
            document.write("<div style='position: absolute; left: 680px; top: 97px;'>"); 
            document.write("<a class='menu' href='/accounts/pickup/index.aspx'>"); 
            document.write("Pick up");
            document.write("</a>"); 
            document.write("</div>"); 
            document.write("<div style='position: absolute; left: 680px; top: 124px;'>"); 
            document.write("<a class='menu' href='/company/contactus.aspx'>"); 
            document.write("Contact Us");
            document.write("</a>"); 
            document.write("</div>"); 
            document.write("</div>");                
            document.write(' </td>');
            document.write('  </tr>');
            document.write('  <tr>');
            document.write('    <td align="center" background="/Images/flash_error_bg.gif">');
                                        
            document.write(alternateContent); 
            document.write('    </td>');
            document.write('  </tr>');
            document.write('</table>');
           
            document.write('</td>');
            document.write('</tr>');
            document.write('</table>');
            
        } else {
            
            document.write(alternateContent); 
            document.write('    </td>');
            document.write('  </tr>');
            document.write('</table>');
            
          
        }
		
	}
    
}

function calculateWidth(objElement)
	{
			var intWidth = 0;

            intWidth =  objElement.offsetWidth;
            return intWidth;
	
	}
	
function calculateHeight(objElement)
	{
		
			var intHeight = 0;

            intHeight =  objElement.offsetHeight;
			
            return intHeight;
	
	}
	
function calculateLeft(objElement)
{
        var intLeft = 0;
        var objOffSetparent = objElement;

         while(objOffSetparent)
        {
              intLeft += objOffSetparent.offsetLeft;
              objOffSetparent = objOffSetparent.offsetParent;
        }
        return intLeft;
}

 
function calculateTop(objElement)
{
        var intTop = 0;
        var objOffSetparent = objElement;

        while(objOffSetparent)
        {
                intTop += objOffSetparent.offsetTop;
                objOffSetparent = objOffSetparent.offsetParent;
        }
        return intTop;
}
	
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function showHideCombo(bShowHide)
{
    oSelect = document.getElementsByTagName("SELECT");
    
    if(oSelect)
    {
        for(var i = 0 ; i < oSelect.length ; i++)
        {
            oSelect(i).style.visibility=bShowHide;
        }
    } 
} 
