﻿/* ------------------------------------------------------------
 * Name      : common.js
 * Desc       : Common Index script 
 * Created   : 2010/02/15 common js by Ali Dadgar
 ------------------------------------------------------------ */

//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 ''; 
}





   function lightup(imageobject, opacity){
    if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5)
    imageobject.style.MozOpacity=opacity/100
    else if (navigator.appName.indexOf("Microsoft")!=-1&&parseInt(navigator.appVersion)>=4)
    imageobject.filters.alpha.opacity=opacity
}

var currenttt_layer;

function layer(id1)
{

	lightup(id1,100);

    if(currenttt_layer)
    {
        
		lightup(currenttt_layer,45);
    }
    currenttt_layer=id1;

    if(id1==currenttt_layer)
    {
        
		lightup(id1,100);
    }


}
var over_layer;
function rollover(id1)
{

    if(id1!=currenttt_layer)
    {
        
		lightup(id1,100);
    }

}

function rollout(id1)
{

    if(id1!=currenttt_layer)
    {
        
		lightup(id1,45);
    }

}

/***********************************************
* AnyLink Drop Down Menu
* This notice MUST stay intact for legal use
***********************************************/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<div id="#bgtopnav"><img src="common/img/main/subnav5.png" class="png24" ></div><div id="CNTdropmenudiv" ><img src="common/img/nav/1.gif" ><div id="CNTinter">'
menu1[1]='<a class="normal" href="common/html/about/golestanco/overview/index.html">معرفي گلستان</a>'
menu1[2]='<a class="normal" href="common/html/about/careers/overview/index.html" >نيروي انساني</a>'
menu1[3]='<a class="normal" href="common/html/about/crm/overview/index.html" >ارتباط با مشتريان</a>'
menu1[4]='<a class="normal" href="common/html/about/commitment/overview/index.html" >فعاليتهاي اجتماعي</a>'
menu1[5]='<a class="normal" href="common/html/about/mediacenter/overview/index.html" >گلستان در رسانه ها</a></div></div>'

//Contents for menu 2
var menu2=new Array()
menu2[0]='<div id="#bgtopnav"><img src="common/img/main/subnav3.png" class="png24" ></div><div id="CNTdropmenudiv" ><img src="common/img/nav/2.gif" ><div id="CNTinter">'
menu2[1]='<a class="normal" href="common/html/products/golestan/overview/index.html">گلستان</a>'
menu2[2]='<a class="normal" href="common/html/products/pardis/overview/index.html">پرديس</a>'
menu2[3]='<a class="normal" href="common/html/products/twinings/overview/index.html">توئينينگز</a>'
menu2[4]='<a class="normal" href="common/html/products/hotikara/overview/index.html">هاتي كارا</a>'
menu2[5]='<a class="normal" href="common/html/products/royal/overview/index.html">رويال</a>'
menu2[6]='<a class="normal" href="common/html/products/golkis/overview/index.html">گل كيس</a>'
menu2[7]='<a class="normal" href="common/html/products/lamb/overview/index.html">بره نشان</a>'
menu2[8]='<a class="normal" href="common/html/products/camel/overview/index.html">شتر نشان</a></div></div>'

//Contents for menu 5, and so on
var menu5=new Array()
menu5[0]='<div id="#bgtopnav"><img src="common/img/main/subnav1.png" class="png24" ></div><div id="CNTdropmenudiv" ><img src="common/img/nav/5.gif" ><div id="CNTinter">'
menu5[1]='<a class="normal" href="common/html/news/company/headlines/index.html">اخبار گلستان</a>'
menu5[2]='<a class="normal" href="common/html/news/company/events/index.html" >رويدادهاي گلستان</a>'
menu5[3]='<a class="normal" href="common/html/news/company/newsletter/index.html" >اشتراك در خبرنامه</a>'
menu5[4]='<a class="normal" href="blog.html" target="_blank">گلستان بلاگ</a></div></div>'

//Contents for menu 3, and so on
var menu3=new Array()
menu3[0]='<div id="#bgtopnav"><img src="common/img/main/subnav2.png" class="png24" ></div><div id="CNTdropmenudiv" ><img src="common/img/nav/3.gif" ><div id="CNTinter">'
menu3[1]='<a class="normal" href="common/html/sales/salesdept/overview/index.html" >معرفي سازمان فروش</a>'
menu3[2]='<a class="normal" href="common/html/sales/distributiondept/overview/index.html" >معرفي سازمان توزيع</a></div></div>'


//Contents for menu 4, and so on
var menu4=new Array()
menu4[0]='<div id="#bgtopnav"><img src="common/img/main/subnav2.png" class="png24" ></div><div id="CNTdropmenudiv" ><img src="common/img/nav/4.gif" ><div id="CNTinter">'
menu4[1]='<a class="normal" href="common/html/lottery/presentation/overview/index.html" >آشنايي با قرعه كشي</a>'
menu4[2]='<a class="normal" href="common/html/lottery/golestanclub/overview/index.html" >آشنايي با باشگاه گلستان</a></div></div>'

//Contents for menu 6, and so on
var menu6=new Array()
menu6[0]='<div id="#bgtopnav"><img src="common/img/main/subnav4.png" class="png24" ></div><div id="CNTdropmenudiv" ><img src="common/img/nav/6.gif" ><div id="CNTinter">'
menu6[1]='<a class="normal" href="common/html/contact/headoffice/form/index.html">دفتر مركزي</a>'
menu6[2]='<a class="normal" href="common/html/contact/voc/form/index.html">صداي مصرف كنندگان</a>'
menu6[3]='<a class="normal" href="common/html/contact/jobs/form/index.html" >دعوت به همكاري</a></div></div>'


		
var menuwidth='150px' //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
