
var ajax=new sack();
var whichIndex=1;
function getOtherImgNext(prodid,base,totalArrayLength)
	{
		
		if(whichIndex<totalArrayLength)
			{
				ajax.requestFile=base+'/specialoffer/prodid-'+prodid+'/whichindex-'+whichIndex;
				ajax.onLoading=function()
					{
						showLoading(base);
					}
				ajax.onCompletion=showResult;
				ajax.runAJAX();
				whichIndex++;
				
				if(whichIndex >=totalArrayLength)
					{
						document.getElementById('next').innerHTML='<img src="'+base+'/images/next.jpg" border="0" />';
					}
				
document.getElementById('previous').innerHTML='<a href="javascript: void(0);" onclick="getOtherImgPrevious('+prodid+',\''+base+'\','+totalArrayLength+');"><img src="'+base+'/images/prev.jpg" border="0" /></a>	';
				
			}
		
	}

function showLoading(base)
	{
		document.getElementById('imgGallery').innerHTML='<span  style="padding-top:50px; padding-left:50px; padding-bottom:75px;"><img src="'+base+'/images/ajax_load.gif"> &nbsp;&nbsp; Loading  </span>';	
	}
function showResult()
	{
			document.getElementById('imgGallery').innerHTML=ajax.response;
	}

function getOtherImgPrevious(prodid,base,totalArrayLength)
	{
		var prevIndex=whichIndex-2;	
		ajax.requestFile=base+'/specialoffer/prodid-'+prodid+'/whichindex-'+prevIndex;
		ajax.onLoading=function()
			{
				showLoading(base);
			}
		ajax.onCompletion=showResult;
		ajax.runAJAX();
		whichIndex-=1;
		
		document.getElementById('next').innerHTML='<a href="javascript: void(0);" onclick="getOtherImgNext('+prodid+',\''+base+'\','+totalArrayLength+');"><img src="'+base+'/images/next.jpg" border="0" /></a>	';
		
		
		if(whichIndex==1)
			{
				document.getElementById('previous').innerHTML='<img src="'+base+'/images/prev.jpg" border="0" />';	
			}
	}


function getSubCategory(base,catid)
	{
		if(catid!=0)
			{
				document.getElementById('subCategory').options.length = 0;
				ajax.requestFile=base+'/product/getsubcategory/catid-'+catid;
				ajax.onCompletion=showSubCat;
				ajax.runAJAX();
			}
		else	
			{
				document.getElementById('subCategory').options.length = 0;
				document.getElementById('subCategory').options[document.getElementById('subCategory').options.length] = new Option('-- Select Sub Cateogy --','0');
			}
		
	}

function showSubCat()
	{
		eval(ajax.response);
	}

function bringImageToContainer(base,imageName)	
	{
		var splitName=imageName.split('.');
		ajax.requestFile=base+'/product/getmainimage/imagename-'+splitName[0]+'/ext-'+splitName[1];
		ajax.onCompletion=showImage;
		ajax.onLoading=function()
			{
				showImageLoading(base);	
			}
		ajax.runAJAX();
		
	}
function showImageLoading(base)
	{
		document.getElementById('mainPic').innerHTML='<span style="padding-top:115px; padding-left:80px;"><img src="'+base+'/images/ajax_load.gif"> &nbsp;&nbsp; Loading  ......</span>';	
	}
function showImage()
	{
		document.getElementById('mainPic').innerHTML=ajax.response;
	}

messageObj = new DHTML_modalMessage();	// We only create one object of this class
messageObj.setShadowOffset(5);	// Large shadow


function displayMessage(url,width,height)
{
	
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(width,height);
	messageObj.setShadowDivVisible(true);	// Enable shadow for these boxes
	messageObj.display();
}

function closeMessage()
{
	messageObj.close();	
}
	

function checkLoginAndSendComment(base,prodId,which,catOrSubCaId)
	{
		ajax.requestFile=base+'/product/checkloginforcomment';
		ajax.onCompletion=function()
			{
				showCommentResult(base,prodId,which,catOrSubCaId);
			}
		ajax.runAJAX();
	}

function showCommentResult(base,prodId,which,catOrSubCaId)
	{
		if(ajax.response=='notlogged')
			{
				alert('You Arenot Logged In. Please Login To Post Your Comment !!!');
			}
		else
			{
				if(which=='subcatid')
					{
						displayMessage(base+'/product/makecomment/prodid-'+prodId+'/subcatid-'+catOrSubCaId,650,325);return false
					}
				else
					{
						displayMessage(base+'/product/makecomment/prodid-'+prodId+'/catid-'+catOrSubCaId,650,325);return false	
					}
			}
	}

function validateMakeOfferField()
	{
		var error='';
		if(document.getElementById('fullName').value=='')
			{
				error+='Full Name Is Required !!!\n';
			}
		if( document.getElementById("email").value=="")
		 	{
            	error=error + "Email Is Required !!!\n";
			}
		else
			{
				var txt=document.getElementById("email").value;
	 			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(txt))
            		{

            		}
				 else

            		{
            			error=error + "Email  is not valid !!!\n";
					}
	
			}
		if(document.getElementById('message').value=='')
			{
				error+='Message Is Required !!!\n';
			}
		if(error=='')
			{
				return true;
			}
		else
			{
				alert(error);
				return false;
			}
	}
	
function validateMakeCommentField()
	{
		var error='';
		if(document.getElementById('title').value=='')
			{
				error+='Title Is Required !!!\n';
			}
		if(document.getElementById('comment').value=='')
			{
				error+='Comment Is Required !!!\n';
			}
		if(error=='')
			{
				return true;
			}
		else
			{
				alert(error);
				return false;
			}
	}
	
	
	
	
	
	
	
	
