
handleLoginResponse = function(msg) {
	// response of the login process is sent through HiddenLoginIFrame..
	var loginDiv = window.parent.document.getElementById('loginDiv');
	if(loginDiv)
		Element.Methods.update(loginDiv, msg);
	
	var IFrameObj = document.getElementById('loginframe');
	var IFrameDoc = getIFrameDoc(IFrameObj);
	IFrameDoc.location.replace(IFrameObj.src);
}

getIFrameDoc = function (IFrameObj){
	
  var IFrameDoc;
	//Get the IFrameDoc according to Browser type.
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } 
  return IFrameDoc;
}


postFormToIFrame = function(loginFormObj) {

  var IFrameObj = document.getElementById('loginframe'); // our IFrame object
  var IFrameDoc = getIFrameDoc(IFrameObj);
  
  if(IFrameDoc){
    var IFrameLoginForm = IFrameDoc.getElementById("IFrameLoginForm");
	if(IFrameLoginForm){
		try{
			IFrameDoc.getElementById('mySonyId').value = document.getElementById('mySonyId').value;
			IFrameDoc.getElementById('password').value = document.getElementById('password').value;
			IFrameDoc.getElementById('csi').value = document.getElementById('rememberMe').checked;
			IFrameDoc.getElementById('overridelinksecure').value = document.getElementById('overridelinksecure').value;
			if(document.getElementById('pageStyle')!=null)
				IFrameDoc.getElementById('pageStyle').value = document.getElementById('pageStyle').value;
			if(document.getElementById('authStartedFrom')!=null)
				IFrameDoc.getElementById('authStartedFrom').value = document.getElementById('authStartedFrom').value;
			if(document.getElementById('authActionType')!=null)	
				IFrameDoc.getElementById('authActionType').value = document.getElementById('authActionType').value;
			IFrameLoginForm.action = loginFormObj.action;
			IFrameLoginForm.submit();
		} catch(exception) { /* Submit form */return true; }
		return false;
	}
  }
  return true;
}

function postFormToIFrameOld2(formObj) {
  var IFrameObj; // our IFrame object
  if (!document.createElement) {return true};
  var IFrameDoc;
  var URL = '/view/View.action?site=odw_en_GB&page=MySonyHomeAjaxExtension';
  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','hiddenIFrame');
      tempIFrame.style.border='1px';
      tempIFrame.style.width='10px';
      tempIFrame.style.height='10px';
      IFrameObj = document.body.appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['hiddenIFrame'];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML='\<iframe id="hiddenIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer()',10);
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  
  IFrameDoc.location.replace(URL);
  
  // loginform values are passed to iframeform..
  var iframeForm = IFrameDoc.getElementById("loginFormIFrame");
  if(iframeForm){
	IFrameDoc.getElementById('mySonyId').value = document.getElementById('mySonyId').value;
	IFrameDoc.getElementById('password').value = document.getElementById('password').value;
	iframeForm.action = frmObj.action;
	iframeForm.submit();
	return false;
  }else{
  	try{
	  	//Build iframe form...
	  	var tempIFrameForm=IFrameDoc.createElement('form');
	  	tempIFrameForm.setAttribute('id','loginFormIFrame');
	  	tempIFrameForm.setAttribute('action',formObj.action);
	  	tempIFrameForm.setAttribute('method','POST');
	  	var IFrameFormObj = IFrameDoc.body.appendChild(tempIFrameForm);
	  	
	  	var newMySonyId = document.createElement("input");
	  	newMySonyId.setAttribute('id','mySonyId');
	  	newMySonyId.setAttribute('name','mySonyId');
	  	newMySonyId.setAttribute('type','hidden');
	  	newMySonyId.setAttribute('value', document.getElementById('mySonyId').value);
	  	IFrameFormObj.appendChild(newMySonyId);
	  	
	  	var newPassword = document.createElement("input");
	  	newPassword.setAttribute('id','password');
	  	newPassword.setAttribute('name','password');
	  	newPassword.setAttribute('type','hidden');
	  	newPassword.setAttribute('value', document.getElementById('password').value);
	  	IFrameFormObj.appendChild(newPassword);
	  	
	  	var newOverridelinksecure = document.createElement("input");
	  	newOverridelinksecure.setAttribute('id','overridelinksecure');
	  	newOverridelinksecure.setAttribute('name','overridelinksecure');
	  	newOverridelinksecure.setAttribute('type','hidden');
	  	newOverridelinksecure.setAttribute('value', document.getElementById('overridelinksecure').value);
	  	IFrameFormObj.appendChild(newOverridelinksecure);
	  	
	  	//IFrameFormObj.submit();
	  	
  	} catch(exception) {
  		alert(exception);
  		//return true;
  	}
  }
  return false;

}