/***************************************************
 * AWD CMS
 * @author Junwei Cheng <junwei@awebd.com.au>
 * @version 1.0
 ***************************************************/
    var quote;
	
	function swap_ProductImage(str1, str2)
	{ 
	   xmlHttp=GetXmlHttpObject();
	   if (xmlHttp==null)
	   {
		  alert ('Browser does not support HTTP Request');
		  return;
	   }

	   var q = "SwapProductImage";
	   var url='http://www.eciimports.com/ajax.php';	
	   url=url+'?query='+encodeURIComponent(q);	 
	   url=url+'&imageid='+encodeURIComponent(str1);	 
	   url=url+'&productid='+encodeURIComponent(str2);	 
	   quote= str1;
	   xmlHttp.onreadystatechange=ProductImageStateChanged;
	   xmlHttp.open('GET',url,true);
	   xmlHttp.send(null);
	}

	function ProductImageStateChanged() 
	{ 
	   if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete')
	   { 
		  document.getElementById('mainimageblock').innerHTML=xmlHttp.responseText; 
		  
		  for(var i=1; i<=4; i++)
		  {
			  if(i == quote)
			  {
				  $('#'+quote).removeClass("thumb_unselected");
		          $('#'+quote).addClass("thumb_selected");
			  }
			  else
			  {
				  $('#'+i).removeClass("thumb_selected");
		          $('#'+i).addClass("thumb_unselected");
			  }
		  }

		  			$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
	   } 
	}
	
	function rowOverEffect(object) {
	  if (object.className == 'dataTableRow') object.className = 'dataTableRowOver';
	}
	
	function rowOutEffect(object) {
	  if (object.className == 'dataTableRowOver') object.className = 'dataTableRow';
	}	

	function rowOverEffectCursor(object) {
	  if (object.className == 'dataTableRow') object.className = 'dataTableRowOverCursor';
	}
	
	function rowOutEffectCursor(object) {
	  if (object.className == 'dataTableRowOverCursor') object.className = 'dataTableRow';
	}

	function GetXmlHttpObject()
	{
	   var xmlHttp=null;
	   
	   try
	   {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
	   }
	   catch (e)
	   { 
		  //Internet Explorer
		  try
		  {
			 xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
		  }
		  catch (e)
		  {
			 xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
		  }
	   }
	   return xmlHttp;
	} 
