﻿/* ------------------------------------------------------------
 * Name      : common.js
 * Desc       : PentaBreed script 
 * Created   : 2008/02/28 PentaBreed by Suga
 ------------------------------------------------------------ */

//for IE png
function setPng24(obj) { 
	obj.width=obj.height=1; 
	obj.className=obj.className.replace(/\bpng24\b/i,''); 
	obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
	obj.src='';  
	return ''; 
}


/***********************************************
* AnyLink Drop Down Menu- Â© Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<div id="#bgtopnav"><img src="http://www.assanmotor.com/common/img/main/subnav1.png" class="png24" ></div><div id="CNTdropmenudiv" ><img class="navthumb" src="http://www.assanmotor.com/common/img/nav/santafe.gif" ><a class="normal" href="http://www.assanmotor.com/common/html/showroom/passenger/Centennial/index_centennial.html">سنتنيال</a>'
menu1[1]='<a class="normal" href="http://www.assanmotor.com/common/html/showroom/passenger/genesis/index_genesis.html">جنسيس</a>'
menu1[2]='<a class="normal" href="http://www.assanmotor.com/common/html/showroom/passenger/genesis_coupe/index_genesis.html">جنسيس كوپه</a>'
menu1[3]='<a class="normal" href="http://www.assanmotor.com/common/html/showroom/passenger/azera/index_azera.html">آزرا</a>'
menu1[4]='<a class="normal" href="http://www.assanmotor.com/common/html/showroom/passenger/sonata/index_sonata.html">سوناتا</a>'
menu1[5]='<a class="normal" href="http://www.assanmotor.com/common/html/showroom/passenger/i30/index_i30.html">i30</a>'
menu1[6]='<a class="normal" href="http://www.assanmotor.com/common/html/showroom/recreational/ix55/index_ix55.html">ix55</a>'
menu1[7]='<a class="normal" href="http://www.assanmotor.com/common/html/showroom/recreational/santaFe/index_santaFe.html">سانتافه</a>'
menu1[8]='<a class="normal" href="http://www.assanmotor.com/common/html/showroom/recreational/tucson/index_tucson.html">توسان</a>'
menu1[9]='<a class="normal" href="http://www.assanmotor.com/common/html/showroom/recreational/h1/index_h1.html">H1</a></div>'
//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<div id="#bgtopnav"><img src="http://www.assanmotor.com/common/img/main/subnav1.png" class="png24" ></div><div id="CNTdropmenudiv" ><img class="navthumb" src="http://www.assanmotor.com/common/img/nav/sales.gif" ><a class="maint" href="http://www.assanmotor.com/common/html/sales/qualified/price/index.html?submenuheader=0">شرايط فروش</a>'
menu2[1]='<a class="maint" href="http://www.assanmotor.com/common/html/sales/agents/network/index.html?submenuheader=1">عامليتهاي مجاز</a>'
menu2[2]='<a class="maint" href="../../../sales/onlinesales/request/Default.aspx">خريد آنلاين خودرو</a>'
menu2[3]='<a class="maint" href="http://www.assanmotor.com/common/html/sales/checkstatus/Report/index.html">پيگيري وضعيت خريد</a>'
menu2[4]='<a class="maint" href="http://www.assanmotor.com/common/html/sales/numbering/overview/index.html">راهنماي شماره گذاري</a></div>'
//Contents for menu 3, and so on
var menu3=new Array()
menu3[0]='<div id="#bgtopnav"><img src="http://www.assanmotor.com/common/img/main/subnav1.png" class="png24" ></div><div id="CNTdropmenudiv" ><img class="navthumb" src="http://www.assanmotor.com/common/img/nav/aftersales.gif" ><a class="maint" href="http://www.assanmotor.com/common/html/aftersales/services/vip/index.html" >گستره خدمات</a>'
menu3[1]='<a class="maint" href="http://www.assanmotor.com/common/html/aftersales/agents/network/index.html">عامليتهاي مجاز</a>'
menu3[2]='<a class="maint" href="http://www.assanmotor.com/common/html/aftersales/gurantee/terms/index.html">گارانتي</a>'
menu3[3]='<a class="maint" href="http://www.assanmotor.com/common/html/aftersales/parts/overview/index.html" >قطعات</a>'
menu3[4]='<a class="maint" href="http://www.assanmotor.com/common/html/aftersales/onlineservices/overview/index.html" >پذيرش اينترنتي</a></div>'

//Contents for menu 4, and so on
var menu4=new Array()
menu4[0]='<div id="#bgtopnav"><img src="http://www.assanmotor.com/common/img/main/subnav1.png" class="png24" ></div><div id="CNTdropmenudiv" ><img class="navthumb" src="http://www.assanmotor.com/common/img/nav/about.gif" ><a class="maint" href="http://www.assanmotor.com/common/html/about/assanmotor/company/index.html?submenuheader=0">درباره آسان موتور</a>'
menu4[1]='<a class="maint" href="http://www.assanmotor.com/common/html/about/hyundai/company/index.html?submenuheader=1" >درباره هيونداي موتور</a>'
menu4[2]='<a class="maint" href="http://www.assanmotor.com/common/html/about/hyundai/intheworld/index.html" >هيونداي در جهان</a>'
menu4[3]='<a class="maint" href="http://www.assanmotor.com/common/html/about/gallery/brochure/index.html?submenuheader=2" >گالري</a>'
menu4[4]='<a class="maint" href="http://www.assanmotor.com/common/html/about/news/headlines/index.html" >اخبار شركت</a>'
menu4[5]='<a class="maint" href="http://www.assanmotor.com/common/html/about/carshow/headlines/index.html" >رويدادهاي نمايشگاهي</a></div>'
		
var menuwidth='508px' //default menu width
var menubgcolor='lightyellow'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="no" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

