
preLoadPic = new Array();
function preLoad() {
	pic = new Array();
	pic[0]  = '../guest/img/home-pic01.jpg';
//	pic[1]  = '../guest/img/home-pic02.jpg';
	pic[1]  = '../guest/img/home-pic03.jpg';
	pic[2]  = '../guest/img/home-pic04.jpg';
//	pic[3]  = '../guest/img/home-pic05.jpg';
	pic[3]  = '../guest/img/home-pic06.jpg';
	pic[4]  = '../guest/img/home-pic07.jpg';
	pic[5]  = '../guest/img/product1-on.gif';
	pic[6]  = '../guest/img/product2-on.gif';
	pic[7]  = '../guest/img/product3-on.gif';
	pic[8] = '../guest/img/product4-on.gif';
	pic[9] = '../guest/img/product5-on.gif';
	pic[10] = '../guest/img/product6-on.gif';
	pic[11] = '../guest/img/product7-on.gif';
	pic[12] = '../guest/img/product8-on.gif';

	for (i = 0; i < pic.length; i ++) {
		preLoadPic[i] 		= new Image();
		preLoadPic[i].src 	= pic[i];
	}
}

function menuOver(objId, objClass) {
	document.getElementById(objId).className = objClass;
}

function menuOut(objId, objClass) {
	document.getElementById(objId).className = objClass;
}

j = 0;
function runSlideShow() {
	var p = 5;
	var slideShowSpeed = 5000;
	var crossFadeDuration = 2;
	
	if(document.all) {
		document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
		document.images.SlideShow.filters.blendTrans.Apply();
	}
	document.images.SlideShow.src = preLoadPic[j].src;
	if(document.all) {
		document.images.SlideShow.filters.blendTrans.Play();
	}
	
	j = j + 1;
	if(j > (p - 1))
		j = 0;
	
	var t = setTimeout('runSlideShow()', slideShowSpeed);
}

function changeNavImages(elementId, lang) {
	for (i = 1; i <= 8; i ++) {
		if(lang == 'en' && elementId == 'nav1') {
			if (document.getElementById('nav' + i)) {
					document.getElementById('nav' + i).src = '../guest/img/nav' + i + '_off.gif';
				}
			document.getElementById(elementId).src = '../guest/img/' + elementId + '_on_en.gif';
		} else if(lang == 'en' && elementId != 'nav1') {
			if (document.getElementById('nav' + i)) {
					document.getElementById('nav' + i).src = '../guest/img/nav' + i + '_off.gif';
				}
			document.getElementById('nav' + 1).src = '../guest/img/nav' + 1 + '_off_en.gif';
			document.getElementById(elementId).src = '../guest/img/' + elementId + '_on.gif';
		}else if(lang == 'fa' && elementId == 'nav1') {
			if (document.getElementById('nav' + i)) {
					document.getElementById('nav' + i).src = '../guest/img/nav' + i + '_off.gif';
				}
			document.getElementById(elementId).src = '../guest/img/' + elementId + '_on_fa.gif';
		} else if(lang == 'fa' && elementId != 'nav1') {
			if (document.getElementById('nav' + i)) {
					document.getElementById('nav' + i).src = '../guest/img/nav' + i + '_off.gif';
				}
			document.getElementById('nav' + 1).src = '../guest/img/nav' + 1 + '_off_fa.gif';
			document.getElementById(elementId).src = '../guest/img/' + elementId + '_on.gif';
		}
	}
}

function showDetails(elementId) {
  for(k = 1; k <= 8; k ++) {
	if (document.getElementById('Details' + k))
	document.getElementById('Details' + k).style.display = 'none';
  }
  document.getElementById(elementId).style.display = '';
}

function toggle(id) {
	if(document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = '';
	} else {
		document.getElementById(id).style.display = 'none';
	}
}

function makePopup(pageURL, pageName, w, h, pageScroll, pageCenter)
{
	var w = parseInt(w);
	var h = parseInt(h);
	if(pageCenter == 'no')	{
		LeftPosition = 10;
		TopPosition = 10;
	} else {
		LeftPosition = (screen.width) ? (screen.width-w) / 2 : 0;
		TopPosition = (screen.height) ? (screen.height-h) / 2 : 0;
	}

	var pageConfig = 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=' + pageScroll + ', resizable=yes, width=' + (w + 18) + ', height=' + (h + 18) + ', left=' + LeftPosition + ', top=' + TopPosition;
	var popup = window.open(pageURL, pageName, pageConfig);
	popup.focus();
	return popup;
}


// Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEOVER);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position
        // reflects the position from the top/left of the screen the
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}

cityInfo = new Array();
cityInfo['Mashad'] = '<span style="color: #B50000; ">Mashad</span><br />' +
'Tel: (0511) 2222564<br />' +
'Fax: (0511) 2252881';
cityInfo['Kerman'] = '<span style="color: #B50000; ">Kerman</span><br />' +
'Tel: 88320043<br />' +
'Fax: 88306503';
cityInfo['Esfahan'] = '<span style="color: #B50000; ">Esfahan</span><br />' +
'Tel: (0311) 2337000<br />' +
'Fax: (0311) 2364595';
cityInfo['Sary'] = '<span style="color: #B50000; ">Sary</span><br />' +
'Tel: (0151) 3259269<br />' +
'Fax: (0151) 3259269';
cityInfo['Tehran'] = '<span style="color: #B50000; ">Tehran</span><br />' +
'Branch Office: No. 1, North Lalezar Ave., Tehran 11449, Iran.<br />' +
'Tel: (021) 33913030, 33113131<br />' +
'Fax: (021) 33935118';
cityInfo['Qazvin'] = '<span style="color: #B50000; ">Qazvin</span><br />' +
'Tel: (0281) 3344224<br />' +
'Fax: (0281) 3344224';
cityInfo['Tabriz'] = '<span style="color: #B50000; ">Tabriz</span><br />' +
'Tel: (0411) 5552657<br />' +
'Fax: (0411) 5547190';
cityInfo['Shahrood'] = '<span style="color: #B50000; ">Shahrood</span><br />' +
'Tel: (0273) 2222280<br />' +
'Fax: (0273) 2222280';
cityInfo['Yazd'] = '<span style="color: #B50000; ">Yazd</span><br />' +
'Tel: (0351) 6269695<br />' +
'Fax: (0351) 6264563';
cityInfo['Shiraz'] = '<span style="color: #B50000; ">Shiraz</span><br />' +
'Tel: (0711) 2341694<br />' +
'Fax: (0711) 2308865';
cityInfo['Rasht'] = '<span style="color: #B50000; ">Rasht</span><br />' +
'Loostr-e-Ferdowsi: Corner of 87, Golsar, Rasht<br />' +
'Tel: 7223496, 7227850 (0131)<br />' +
'Fax: 7224397 (0711)';
cityInfo['Chaloos'] = '<span style="color: #B50000; ">Chaloos</span><br />' +
'Darya Cheraghan: Near Sardabroud BridgeT After Kamarbandi, Tonekabon Rood Chalous,<br />' +
'Tel: 2252464 (0191)<br />' +
'Fax: 2250024 (0191)';
cityInfo['FAMashad'] = '<span style="color: #B50000; ">مشهد</span><br />' +
'تلفن: 2222564 (0511)</span><br />' +
'فکس: 2252881 (0511)';
cityInfo['FAKerman'] = '<span style="color: #B50000; ">کرمان</span><br />' +
'تلفن: 88320043<br />' +
'فکس: 88306503';
cityInfo['FAEsfahan'] = '<span style="color: #B50000; ">اصفهان</span><br />' +
'تلفن: 2337000 (0311)<br />' +
'فکس: 2364595 (0311)';
cityInfo['FASary'] = '<span style="color: #B50000; ">ساری</span><br />' +
'تلفن: 3259269 (0151)<br />' +
'فکس: 3259269 (0151)';
cityInfo['FATehran'] = '<span style="color: #B50000; ">تهران</span><br />' +
'فروشگاه جار لاله زار: خيابان لاله زار جنوبی، نبش خيابان اکباتان، پلاک 1<br />' +
'کدپستی: 11449<br />' +
'تلفن: 33913030, 33113131 (021)<br />' +
'فکس: 33935118 (021)';
cityInfo['FAQazvin'] = '<span style="color: #B50000; ">قزوين</span><br />' +
'تلفن: 3344224 (0281)<br />' +
'فکس: 3344224 (0281)';
cityInfo['FATabriz'] = '<span style="color: #B50000; ">تبريز</span><br />' +
'تلفن: 5552657 (0411)<br />' +
'فکس: 5547190 (0411)';
cityInfo['FAShahrood'] = '<span style="color: #B50000; ">شاهرود</span><br />' +
'تلفن: 2222280 (0273)<br />' +
'فکس: 2222280 (0273)';
cityInfo['FAYazd'] = '<span style="color: #B50000; ">يزد</span><br />' +
'تلفن: 6269695 (0351)<br />' +
'فکس: 6264563 (0351)';
cityInfo['FAShiraz'] = '<span style="color: #B50000; ">شيراز</span><br />' +
'تلفن: 2341694 (0711)<br />' +
'فکس: 2308865 (0711)';
cityInfo['FARasht'] = '<span style="color: #B50000; ">رشت</span><br />' +
'لوستر فردوسی: رشت، گلسار، نبش 87<br />' +
'تلفن: 7223496, 7227850 (0131)<br />' +
'فکس: 7224397 (0131)';
cityInfo['FAChaloos'] = '<span style="color: #B50000; ">چالوس</span><br />' +
'دريا چراغان: چالوس، جاده تنکابن، بعد از کمربندی، جنب پل سردآبرود<br />' +
'تلفن: 2252464 (0191)<br />' +
'فکس: 2250024 (0191)';

function showAgent(city) {
	captureMousePosition;
	document.getElementById('agent').style.display = '';
	document.getElementById('agent').style.top = yMousePos + 'px';
	document.getElementById('agent').style.left = (xMousePos - 100) + 'px';
	document.getElementById('agent').innerHTML = cityInfo[city];
}

function hideAgent() {
	document.getElementById('agent').style.display = 'none';
}

function addOrder(lang, id) {
	if(lang == 'en') {
		document.getElementById('OrderList').value += 
		"Product Brand & Group:\r" + document.getElementById('_brand').value + "\r" +
		"Product Name:\r" + document.getElementById('_product-' + id).value + "\r" +
		"Product Count:\r" + document.getElementById('_count').value + "\r" +
		"Product Comment:\r" + document.getElementById('_comment').value + "\r" +
		"-----------------------------------------------------------------\r";
	} else if(lang == 'fa') {
		document.getElementById('OrderList').value += 
		"نوع و گروه محصول:\r" + document.getElementById('_brand').value + "\r" +
		"نام محصول:\r" + document.getElementById('_product-' + id).value + "\r" +
		"تعداد:\r" + document.getElementById('_count').value + "\r" +
		"توضيحات:\r" + document.getElementById('_comment').value + "\r" +
		"-----------------------------------------------------------------\r";
	}
}

function showHide(objId, lang) {
	if(lang == 'fa') {
		if(objId == 'page1') {
			document.getElementById('image').innerHTML = '<img alt="" src="../guest/img/fa/customer01.gif" width="491" height="736" />';
		} else if(objId == 'page2') {
			document.getElementById('image').innerHTML = '<img alt="" src="../guest/img/fa/customer02.gif" width="491" height="736" />';
		}
	}
	if(lang == 'en') {
		if(objId == 'page1') {
			document.getElementById('image').innerHTML = '<img alt="" src="../guest/img/en/customer01.gif" width="491" height="839" />';
		} else if(objId == 'page2') {
			document.getElementById('image').innerHTML = '<img alt="" src="../guest/img/en/customer02.gif" width="491" height="784" />';
		}
	}
}

function init(lang) {
	if(document.getElementById('_brand').value == '') {
		if(idBack) {
			document.getElementById('product-' +  idBack).style.display = 'none';
			document.getElementById('addButton').onclick = '';
		}
		document.getElementById('_product').style.display = '';
	} else {
		if(document.getElementById('_product').style.display == '') {
			document.getElementById('_product').style.display = 'none';
		}
		if(idBack) {
			document.getElementById('product-' +  idBack).style.display = 'none';
		}
		var id = document.getElementById('_brand').options[document.getElementById('_brand').selectedIndex].id;
		document.getElementById('product-' + id).style.display = '';
		idBack = id;
		
		document.getElementById('addButton').onclick = function() 	{
																	addOrder(lang, id);
																	};
	}
}
