// JavaScript Document
/// car prize
var carPrize	=	['$29,000','$30,100','$35,400','$50,400','$40,300','$45,200','$53,400','$57,200','$113,100','$122,100'];

	function findPosition( oLink ) //function to get the position of the link to open the window[contact name ]
	{
		if( oLink.offsetParent ) 
		{
			for( var posX = 0, posY = 0; oLink; oLink = oLink.offsetParent ) {
			posX += oLink.offsetLeft;
			posY += oLink.offsetTop;
		}
		return posX+','+posY ;
		} else {
		return  oLink.x+','+oLink.y;
		}
	}	
	
	var win = null;
	function NewWindow(mypage,myname,w,h,scroll)
	{
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings =
		'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
		win = window.open(mypage,myname,settings)
	}
	
	function closeWin(id){
		document.getElementById(id).style.display='none';
	}

function getVersionList(url, make, mod, showall, index){
	url = url+'/adMain/setObjId_getVersionList/'+index+'/'+make+'/'+mod+'/'+showall+'/';
	ajaxCall('dvVr'+index,url);
}

function setNgetModelList(obj, url,val,showall, index){
	url = url+'/adMain/setObjId_getModelList/'+obj+'/'+val+'/'+showall+'/';
	ajaxCall('dv'+index,url);	
}

function getModelsIntoDiv(url,val,showall, index){
	url = url+'/adMain/getModelList/'+val+'/'+showall+'/';
	ajaxCall('dv'+index,url);
}

function getArticleSub(url,val){
	url = url+'/adMain/ajax_articleSubCat/'+val+'/';
	ajaxCall('divSubCat',url);
}

function getModels(url,val,showall){
	url = url+'/adMain/getModelList/'+val+'/'+showall+'/';
	ajaxCall('ModelList',url);
}

function delCarDetail(url,recId, ArticleId){
	document.getElementById("DelMsg").style.display = 'block';
	url = url+'/adMain/delCarDetail/'+recId+'/'+ArticleId+'/';
	ajaxCall('DelMsg', url);	
}

function delArticleImage(url, imgID, imgType, ArticleId){
	document.getElementById("divdelmsg").style.display = 'block';
	url = url+'/adMain/delArticleImage/'+imgID+'/'+imgType+'/'+ArticleId+'/';
	ajaxCall('divdelmsg', url);	
}

function viewEditorialArticle(url,val){
	url = url+'/adMain/PopUpEditorial/'+val+'/';
	ajaxCall('fixedtipdiv', url);
}

function ShowTab(type){
	var j,k,i,arr;
	j = document.getElementById('viewedSpan');
	k = document.getElementById('emailedSpan');	
	arr = new Array()
	arr[0] = 'viewed';
	arr[1] = 'emailed';
	arr[2] = 'searched';

	for(i=0;i<=2;i++)
	{
		j = document.getElementById(arr[i]+'Span');
		k = document.getElementById(arr[i]+'Tab');	
		j.className = "";
		k.style.display = "none";
		document.getElementById(arr[i]).className='';
	}
	/*document.getElementById('viewed').className='';
	document.getElementById('emailed').className='';
	document.getElementById('searched').className='';*/

		j = document.getElementById(type+'Span');
		k = document.getElementById(type+'Tab');	
		j.className = "selected";
		k.style.display = "block";	
		document.getElementById(type).className='selectedTab';
}


function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

function swapImg(){
		var imgPath=document.getElementById('currentImage').src
		var arrPos=getPosition(imagePath,imgPath);
		document.getElementById('currentImage').src=imagePath[arrPos]
		if(document.getElementById('captionHolder')){
			document.getElementById('captionHolder').innerHTML=imageCaption[arrPos];
		}
		document.getElementById('counterSpan').innerHTML='Image :'+eval(arrPos+1)+' of '+imagePath.length+'';
		
	}
	function getPosition(arrayName,arrayItem)
	{
		if(arrayName.length>1){
			var filename1 = arrayItem.substring(arrayItem.lastIndexOf('/')+1);
		for(var i=0;i<arrayName.length;i++){ 
			 var filename2 = arrayName[i].substring(arrayName[i].lastIndexOf('/')+1);
		   if(filename2!=filename1){
				return i;
		   }
		}
		}else{
			return 0;
		}
	}
	
	